<!DOCTYPE html>
<html>
<head>
<include file="Include:meta" />
<title>编辑物资-目的地运营集团数据管理平台</title>
<include file="Include:style" />
</head>
<body>
<include file="Include:header" />
<include file="Include:left" />
<div id="main">
	<div class="crumbs">
		<div class="crumbs-text">物资库 > 编辑物资</div>
	</div>
	<div id="content">
		<form class="material_add" action="__APP__/Administration/material_edit" method="post" enctype="multipart/form-data">
			<input type="hidden" name="action" value="doedit">
			<div class="form-main">
				<div class="form-title">编辑物资</div>
				<div class="form-item">
					<div class="input-label">物资编号</div>
					<div class="input-item">
						{$result['number']}
					</div>
				</div>
				<div class="form-item">
					<div class="input-label"><span class="asterisk">*</span>类型</div>
					<div class="input-item">
						<if condition="$have eq NULL">
							<span class="checkbox-item lx_radio">
								<label class="radio-inline"><input type="radio" name="type" value="1" <if condition="$result['type'] eq '1'">checked</if>>礼品</label>
								<label class="radio-inline"><input type="radio" name="type" value="2" <if condition="$result['type'] eq '2'">checked</if>>办公用品</label>
							</span>
						<else/>
							<if condition="$result['type'] eq 1">礼品<else/>办公用品</if>
							<input type="hidden" name="type" value="{$result['type']}">
						</if>
					</div>
				</div>
				<div class="form-item">
					<div class="input-label"><span class="asterisk">*</span>名称</div>
					<div class="input-item">
						<if condition="$have eq NULL">
							<input type="text" name="name" class="form-control required-text w150" value="{$result['name']}" autocomplete="off">
							<span class="error-item">必填项</span>
						<else/>
							{$result['name']}
							<input type="hidden" name="name" value="{$result['name']}">
						</if>
					</div>
				</div>
				<div class="form-item">
					<div class="input-label"><span class="asterisk">*</span>单位</div>
					<div class="input-item">
						<input type="text" name="unit" class="form-control required-text w150" value="{$result['unit']}" autocomplete="off">
						<span class="error-item">必填项</span>
					</div>
				</div>
				<div class="form-item">
					<div class="input-label"><span class="asterisk">*</span>单价(元)</div>
					<div class="input-item">
						<input type="text" name="price" class="form-control required-text money w150" value="{$result['price']+0}" autocomplete="off">
						<span class="error-item">必填项</span>
						<span class="error-item">必须是大于0且可保留两位小数的数字</span>
					</div>
				</div>
				<div class="form-item">
					<div class="input-label">规格</div>
					<div class="input-item">
						<if condition="$have eq NULL or $result['norms'] eq NULL">
							<input type="text" name="norms" class="form-control w150" value="{$result['norms']}" autocomplete="off">
						<else/>
							{$result['norms']}
							<input type="hidden" name="norms" value="{$result['norms']}">
						</if>
					</div>
				</div>
				<div class="form-item">
					<div class="input-label">品牌</div>
					<div class="input-item">
						<if condition="$have eq NULL or $result['brand'] eq NULL">
							<input type="text" name="brand" class="form-control w150" value="{$result['brand']}" autocomplete="off">
						<else/>
							{$result['brand']}
							<input type="hidden" name="brand" value="{$result['brand']}">
						</if>
					</div>
				</div>
			</div>
			<p class="Text_c" style="color: #a94442;"></p>
			<div class="form-btn-item"><button class="btn submit" type="button">生成</button><button class="btn btn-default goback" type="button">返回</button></div>
		</form>
	</div>
</div>
<include file="Include:javascript" />
<script type="text/javascript">
$(function(){
	//提交验证
	$(".submit").click(function(){
		var tag = true;

		$(".required-text").each(function(){
			var val = $(this).val();
			if(val=="" || /^\s+$/.test(val)){
				$(this).next(".error-item").show();
				tag = false;
			}
		});
		var val = $('.money').val();
		if(!/^(([1-9]+)|([0-9]+\.[0-9]{1,2}))$/.test(val) && val!=""){
			$('.money').nextAll(".error-item").eq(1).show();
			tag = false;
		}

		if(tag){
			$.ajax({
				type:"POST",
				async:false,
				dataType:"json",
				data:$('.material_add').serialize(),
				url:"__APP__/Administration/material_ajax",
				success:function(data){
					if(data.status==1){
						$(".material_add").submit();
					}else{
						$('.Text_c').html(data.msg);
					}
				}
			})
		}
	});
	
	//隐藏错误提示
	$('.required-text').focus(function(){
		$(this).nextAll(".error-item").hide();
	})
	$('label').click(function(){
		$(this).parent().find(".error-item").hide();
	})
});
</script>
</body>
</html>